import cv2

class rtmpPlayer:

    def __init__(self,rtmpUrl):
        self.cap = cv2.VideoCapture(rtmpUrl)
        self.fps = self.cap.get(cv2.CAP_PROP_FPS)
        self.video_width=self.cap.get(cv2.CAP_PROP_FRAME_WIDTH)
        self.video_height=self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
        self.video_size=(self.video_width,self.video_height)
        print("cap fps:",self.fps)
        print("cap size:", self.video_size)

    def run(self):
        while True:
            ret,frame=self.cap.read()
            if not ret:
                break
            cv2.imshow("video",frame)
            cv2.waitKey(1)  # 延迟

        self.cap.release()




player=rtmpPlayer("rtmp://localhost:1935/live/carstream")
player.run()
